//
//  QNewFeatureCell.m
//  QoilPublic
//
//  Created by 杨凯 on 16/7/4.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "QNewFeatureCell.h"
#import "QMainVC.h"
#import "QNavigationVC.h"
#import "QOilTabBarController.h"
@interface QNewFeatureCell()

@property(nonatomic,strong)UIImageView *picImage;

@property (nonatomic, weak) UIButton *startButton;


@end
@implementation QNewFeatureCell

- (UIImageView *)picImage{
    if(!_picImage){
        UIImageView *imgView1 = [[UIImageView alloc] init];
        _picImage = imgView1;
        [self.contentView addSubview:_picImage];
    }
    return _picImage;
}

- (UIButton *)startButton{
    if (_startButton == nil) {

        UIButton *startBtn = [QViewUtility createButtonWithFrame:CGRectMake((kScreenWidth-100)/2, self.height*0.9, 100, 40) font:17 title:@"立即使用" titleColor:[UIColor colorWithRed:104/255.0 green:126/255.0 blue:241/255.0 alpha:1] backgroundColor:[UIColor clearColor]];
        startBtn.layer.borderWidth = 1;
        startBtn.layer.cornerRadius = 8;
        startBtn.layer.borderColor = [UIColor colorWithRed:104/255.0 green:126/255.0 blue:241/255.0 alpha:1].CGColor;
        [startBtn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:startBtn];
        _startButton = startBtn;
    }
    return _startButton;
}

- (void)setImages:(UIImage *)images{
    _images = images;
    self.picImage.image = _images;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.picImage.frame = self.contentView.bounds;
    self.startButton.center = CGPointMake(self.width * 0.5, self.height * 0.9);
}

- (void)setIndexPath:(NSIndexPath *)indexPath count:(int)count{
    if (indexPath.row == count - 1) {
        self.startButton.hidden = NO;
    }else{
        self.startButton.hidden = YES;
    }
}

- (void)start{
    //QNavigationVC *nav = [[QNavigationVC alloc] initWithRootViewController:[[QMainVC alloc]init]];
    [UIApplication sharedApplication].keyWindow.rootViewController = [[QOilTabBarController alloc] init];
}


@end
